home *** CD-ROM | disk | FTP | other *** search
- Path: cymbal.aix.calpoly.edu!not-for-mail
- From: dstubbs@cymbal.aix.calpoly.edu (Dan Stubbs)
- Newsgroups: comp.lang.c
- Subject: Re: random number
- Date: 4 Feb 1996 19:00:24 -0800
- Organization: California Polytechnic State University, San Luis Obispo
- Message-ID: <4f3rs8$2lvp@cymbal.aix.calpoly.edu>
- References: <1996Feb4.020051.12889@dcs.warwick.ac.uk>
- NNTP-Posting-User: dstubbs@cymbal.aix.calpoly.edu
-
- In article <1996Feb4.020051.12889@dcs.warwick.ac.uk>,
- Daniel Castillo Molero <D.C.Molero@dcs.warwick.ac.uk> wrote:
- >Hi,
- >Could anybody help me to generate some code to produce
- >a random number between -3 and 3 ?
- >I'm trying to useárand(), but since it doesn't receive
-
- Each time you call rand map the result into the interval -3 ... 3.
- You can do this, for example, as follows:
-
- r = (rand() % 7) - 3;
-
- If you are using rand be sure and read about the role of srand
- in "initializing" the sequence of random numbers that are generated.
-
-
-
-